All Packages Class Hierarchy This Package Previous Next Index
Interface javax.servlet.http.HttpServletResponse
- public interface HttpServletResponse
- extends ServletResponse
This interface, implemented by network service developers,
represents an HTTP servlet response. It allows a servlet's service
method to manipulate HTTP-protocol specified header information, and
return data to its client.
-
SC_ACCEPTED
- Status code (202) indicating that a request was accepted for
processing, but was not completed.
-
SC_BAD_GATEWAY
- Status code (502) indicating that the HTTP server received an
invalid response from a server it consulted when acting as a
proxy or gateway.
-
SC_BAD_REQUEST
- Status code (400) indicating the request sent by the client was
syntactically incorrect.
-
SC_CREATED
- Status code (201) indicating the request succeeded and created
a new resource on the server.
-
SC_FORBIDDEN
- Status code (403) indicating the server understood the request
but refused to fulfill it.
-
SC_INTERNAL_SERVER_ERROR
- Status code (500) indicating an error inside the HTTP service
which prevented it from fulfilling the request.
-
SC_MOVED_PERMANENTLY
- Status code (301) indicating that the resource has permanently
moved to a new location, and that future references should use a
new URI with their requests.
-
SC_MOVED_TEMPORARILY
- Status code (302) indicating that the resource has temporarily
moved to another location, but that future references should
still use the original URI to access the resource.
-
SC_NO_CONTENT
- Status code (204) indicating that the request succeeded but that
there was no new information to return.
-
SC_NOT_FOUND
- Status code (404) indicating that the requested resource is not
available.
-
SC_NOT_IMPLEMENTED
- Status code (501) indicating the HTTP service does not support
the functionality needed to fulfill the request.
-
SC_NOT_MODIFIED
- Status code (304) indicating that a conditional GET operation
found that the resource was available and not modified.
-
SC_OK
- Status code (200) indicating the request succeeded normally.
-
SC_SERVICE_UNAVAILABLE
- Status code (503) indicating that the HTTP service is
temporarily overloaded, and unable to handle the request.
-
SC_UNAUTHORIZED
- Status code (401) indicating that the request requires HTTP
authentication.
-
containsHeader(String)
- Returns true if the response message header has a field with
the specified name.
-
sendError(int)
- Sends an error response to the client using the specified
status code and a default message.
-
sendError(int, String)
- Sends an error response to the client using the specified status
code and descriptive message.
-
sendRedirect(String)
- Sends a redirect response to the client using the specified
redirect location URL.
-
setDateHeader(String, long)
-
Adds a field to the response header with a given name and
date-valued field.
-
setHeader(String, String)
-
Adds a field to the response header with a given name and
value.
-
setIntHeader(String, int)
-
Adds a field to the response header with a given name and
integer value.
-
setStatus(int)
- Sets the status code and a default message for this response.
-
setStatus(int, String)
- Sets the status code and message for this response.
SC_OK
public static final int SC_OK
- Status code (200) indicating the request succeeded normally.
SC_CREATED
public static final int SC_CREATED
- Status code (201) indicating the request succeeded and created
a new resource on the server.
SC_ACCEPTED
public static final int SC_ACCEPTED
- Status code (202) indicating that a request was accepted for
processing, but was not completed.
SC_NO_CONTENT
public static final int SC_NO_CONTENT
- Status code (204) indicating that the request succeeded but that
there was no new information to return.
SC_MOVED_PERMANENTLY
public static final int SC_MOVED_PERMANENTLY
- Status code (301) indicating that the resource has permanently
moved to a new location, and that future references should use a
new URI with their requests.
SC_MOVED_TEMPORARILY
public static final int SC_MOVED_TEMPORARILY
- Status code (302) indicating that the resource has temporarily
moved to another location, but that future references should
still use the original URI to access the resource.
SC_NOT_MODIFIED
public static final int SC_NOT_MODIFIED
- Status code (304) indicating that a conditional GET operation
found that the resource was available and not modified.
SC_BAD_REQUEST
public static final int SC_BAD_REQUEST
- Status code (400) indicating the request sent by the client was
syntactically incorrect.
SC_UNAUTHORIZED
public static final int SC_UNAUTHORIZED
- Status code (401) indicating that the request requires HTTP
authentication.
SC_FORBIDDEN
public static final int SC_FORBIDDEN
- Status code (403) indicating the server understood the request
but refused to fulfill it.
SC_NOT_FOUND
public static final int SC_NOT_FOUND
- Status code (404) indicating that the requested resource is not
available.
SC_INTERNAL_SERVER_ERROR
public static final int SC_INTERNAL_SERVER_ERROR
- Status code (500) indicating an error inside the HTTP service
which prevented it from fulfilling the request.
SC_NOT_IMPLEMENTED
public static final int SC_NOT_IMPLEMENTED
- Status code (501) indicating the HTTP service does not support
the functionality needed to fulfill the request.
SC_BAD_GATEWAY
public static final int SC_BAD_GATEWAY
- Status code (502) indicating that the HTTP server received an
invalid response from a server it consulted when acting as a
proxy or gateway.
SC_SERVICE_UNAVAILABLE
public static final int SC_SERVICE_UNAVAILABLE
- Status code (503) indicating that the HTTP service is
temporarily overloaded, and unable to handle the request.
containsHeader
public abstract boolean containsHeader(String name)
- Returns true if the response message header has a field with
the specified name.
- Parameters:
- name - the header field name
setStatus
public abstract void setStatus(int sc,
String sm)
- Sets the status code and message for this response.
- Parameters:
- sc - the status code
- sm - the status message
setStatus
public abstract void setStatus(int sc)
- Sets the status code and a default message for this response.
- Parameters:
- sc - the status code
setHeader
public abstract void setHeader(String name,
String value)
- Adds a field to the response header with a given name and
value. If the field had already been set, the new value
overwrites the previous one. The containsHeader method can be
used to test for the presence of a header before setting its
value.
- Parameters:
- name - the header field name
- value - the header field value
setIntHeader
public abstract void setIntHeader(String name,
int value)
- Adds a field to the response header with a given name and
integer value. If the field had already been set, the new
value overwrites the previous one. The containsHeader method
can be used to test for the presence of a header before setting
its value.
- Parameters:
- name - the header field name
- value - the header field integer value
setDateHeader
public abstract void setDateHeader(String name,
long date)
- Adds a field to the response header with a given name and
date-valued field. The date is specified in terms of
milliseconds since the epoch. If the date field had already
been set, the new value overwrites the previous one. The
containsHeader method can be used to test for the presence of a
header before setting its value.
- Parameters:
- name - the header field name
- value - the header field date value
sendError
public abstract void sendError(int sc,
String msg) throws IOException
- Sends an error response to the client using the specified status
code and descriptive message.
- Parameters:
- sc - the status code
- msg - the detail message
- Throws: IOException
- If an I/O error has occurred.
sendError
public abstract void sendError(int sc) throws IOException
- Sends an error response to the client using the specified
status code and a default message.
- Parameters:
- sc - the status code
- Throws: IOException
- If an I/O error has occurred.
sendRedirect
public abstract void sendRedirect(String location) throws IOException
- Sends a redirect response to the client using the specified
redirect location URL. The URL must be absolute (e.g.,
https://hostname/path/file.html
).
Relative URLs are not permitted here.
- Parameters:
- location - the redirect location URL
- Throws: IOException
- If an I/O error has occurred.
All Packages Class Hierarchy This Package Previous Next Index